package cn.edu.cjw.APMFP.WorkStep.Service;

import java.util.ArrayList;

import cn.edu.cjw.APMFP.WorkStep.DAO.WStepDAO;
import cn.edu.cjw.APMFP.WorkStep.DAO.WStepDAOImpl;
import cn.edu.cjw.APMFP.WorkStep.pojo.WorkStep;

public class WsServiceImpl implements WsService {

	WStepDAO wDao = new WStepDAOImpl();

	public boolean AddWStep(String WId,String WName,String WDescribe) throws Exception {

		// 获取ws的编号，检验ws是否已存在
		if (wDao.searchWStepById(WId).judge()) {
			return false;
		} else {
			WorkStep wStep = new WorkStep(WId, WName, WDescribe);
			return wDao.addAndUpdateWStep(wStep);
		}
	}

	public boolean removeWStep(WorkStep wStep) throws Exception {

		return wDao.removeWStep(wStep);

	}

	public boolean updateWStepName(WorkStep wStep, String nName) throws Exception {
		wStep.setWName(nName);
		return wDao.addAndUpdateWStep(wStep);
	}

	public boolean updateWStepDescribe(WorkStep wStep, String nDescribe) throws Exception {
		wStep.setWDescribe(nDescribe);
		return wDao.addAndUpdateWStep(wStep);
	}

	public boolean updateWStep(WorkStep wStep, String nName, String nDescribe) throws Exception {
		wStep.setWName(nName);
		wStep.setWDescribe(nDescribe);
		return wDao.addAndUpdateWStep(wStep);
	}
	
	public WorkStep searchWStepById(String id) throws Exception {

		return wDao.searchWStepById(id);

	}

	public ArrayList<WorkStep> searchWStepByName(String name) throws Exception {

		return wDao.searchWStepByName(name);
	}

	public ArrayList<WorkStep> showAll() throws Exception {
		return wDao.showAll();
	}

	

}
